﻿using DFGK_WMS.Model.DTO;
using DFGK_WMS.Model.Models;
using NPOI.SS.Formula.Functions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DFGK_WMS.IRepository
{
    /// <summary>
    /// 出库
    /// </summary>
    public interface ITOutboundOrderDetailRepository : IBaseRepository<TShippingOrderDetail>
    {

        /// <summary>
        /// 获取出库单列表
        /// </summary>
        /// <returns></returns>
        List<TShippingOrderDetail> GetShippingOrder();

        /// <summary>
        /// 获取出库单明细表数据
        /// </summary>
        /// <param name="criteria">筛选条件</param>
        /// <returns>返回实体对象</returns>
        TShippingOrderDetail GetShippingOrderDetail(int OrderId);

        /// <summary>
        /// PDA出库反填
        /// </summary>
        /// <returns></returns>
        bool PDAAddShippingOrderDetail(int MaterialId);

        /// <summary>
        /// 修改仓位状态
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        bool UpdateFullStatus(string LocationCode);

        /// <summary>
        /// 修改库区状态
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        bool UpdateAreasStatus(string AreaCode);

        /// <summary>
        /// 库存表删除数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        bool DelTInventoriesById(int id);

        /// <summary>
        /// 出库单明细添加信息
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        bool AddTShippingOrderDetails(TShippingOrderDetail item);

        /// <summary>
        /// 获取出库单明细
        /// </summary>
        /// <returns></returns>
        List<TShippingOrderDetail> GetTShippingOrderDetail(int pageIndex, int pageSize);
        /// <summary>
        /// 获取出库单明细  多个物料版本
        /// </summary>
        /// <returns></returns>
        List<TShippingOrderDetailPlusDTOGroup> GetTShippingOrderDetailPlus(int pageIndex, int pageSize);

        /// <summary>
        /// 根据ID获取出库单详细
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        TShippingOrderDetail GetTShippingOrderDetailById(int id);

        /// <summary>
        /// 根据物料查询库存数量
        /// </summary>
        /// <param name="MaterialsId"></param>
        /// <returns></returns>
        decimal? GetInventoryQty(decimal ? MaterialsId);

        /// <summary>
        /// 根据物料Id查询是否存在此物料
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        List<TMaterial> GetMaterial(int id);

        /// <summary>
        /// 根据库存Id查询库存表中是否存在这条数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        int GetInventory(int id);


        /// <summary>
        /// 根据垛条码查询物料
        /// </summary>
        /// <returns></returns>
        List<TInventory> GetMaterial(string PalletBarcode);

        /// <summary>
        /// 根据物料查询垛条码
        /// </summary>
        /// <returns></returns>
        List<TInventory> GetStackingBarcode(int mid);

        /// <summary>
        /// 根据垛条码查询垛主
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        List<TStackingStorage> GetStackingStacker(string[] PalletBarcode);


        /// <summary>
        /// 根据垛条码删除入库垛信息表中数据
        /// </summary>
        /// <param name="PalletBarcode"></param>
        /// <returns></returns>
        bool DelStackingStorages(string  PalletBarcode);

        /// <summary>
        /// 往库存流水表中插入数据
        /// </summary>
        /// <param name="inventoryLog"></param>
        /// <returns></returns>
        bool CreateInventoryFlow(TInventoryLog item);

        /// <summary>
        /// 首次提交，更新库存中状态
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        int UpdStatus(int id);

        /// <summary>
        /// 获取库存中当前这条数据的状态
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        int GetStatus(int id);

        /// <summary>
        /// 根据ID查询入库垛信息
        /// </summary>
        /// <param name="PalletBarcode"></param>
        /// <returns></returns>
        List<TStackingStorage> GetStackingStorages(string[] PalletBarcode);


        /// <summary>
        /// 根据出库单号获取出库单明细
        /// </summary>
        /// <param name="OrderSn"></param>
        /// <returns></returns>
        List<TShippingOrderDetail> GetDeliveryOrderDetails(string OrderSn);


        /// <summary>
        /// 拣选出库
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        bool AddPickingOutbound(TPickingStationDatum item);

        /// <summary>
        /// 获取拣选出库
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        List<TPickingStationDatum> GetPickingStationDatum(int id);

        /// <summary>
        /// 获取拣选出库详情
        /// </summary>
        /// <param name="PickingStationDataId"></param>
        /// <returns></returns>
        List<TPickingStationDataDetail> GetPickingStationDetail(int PickingStationDataId);

        /// <summary>
        /// 获取库存数量
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        decimal GetInventoryQuantity(int? MaterialId);

        /// <summary>
        /// 减去库存数量并修改库存状态
        /// </summary>
        /// <param name="num"></param>
        /// <returns></returns>
        bool GetDwindleNumbers(TInventory inventory,decimal? num);

        /// <summary>
        /// 往库存流水表添加数据
        /// </summary>
        /// <param name="OrderDTO"></param>
        /// <returns></returns>
        bool AddInventoryFlow(SubmitOutListDTO OrderDTO);

        /// <summary>
        /// 提交出库执行
        /// </summary>
        /// <param name="id"></param>
        /// <param name="shippingOrderDetail"></param>
        /// <returns></returns>
        bool RunShippingOrderDetail(int id, TShippingOrderDetail shippingOrderDetail, out string message);


        /// <summary>
        /// 出库复核
        /// </summary>
        /// <param name="OrderDTO"></param>
        /// <returns></returns>
        bool SubmitOutInventoryReview(SubmitOutListDTO OrderDTO,out string message);

        bool SubmitOutInventoryReviewPlus(SubmitOutListDTO OrderDTO, out string message);


        /// <summary>
        /// 出库解绑
        /// </summary>
        /// <param name="palletBarcode"></param>
        /// <returns></returns>
        bool HandleUnbindOfOutstorage(SubmitOutListDTO OrderDTO , out string message);

        bool HandleUnbindOfOutstoragePlus(SubmitOutListDTO OrderDTO, out string message);



        /// 查询出库单相关数据
        List<CreateOutboundOrderDTO> GetOutboundOrder(string PalletBarcode);

        List<CreateOutboundOrderDTO> GetPalletBarcodePDA(int OrderDetailId);


        /// <summary>
        /// 获取状态为1的出库单号
        /// </summary>
        /// <returns></returns>
        List<string> GetAllShippingOrderSn();

        /// <summary>
        /// 根据单号查询信息
        /// </summary>
        /// <param name="OrderSn"></param>
        /// <returns></returns>
        ShippingLockCellDto GetShippingByOrderSn(string OrderSn);

        /// <summary>
        /// 更新状态（有网）
        /// </summary>
        /// <param name="shippingLockUpdDto"></param>
        /// <returns></returns>
        bool UpdShippingLock(ShippingLockUpdDto shippingLockUpdDto,out string message);

        /// <summary>
        /// 获取此巷道是不是最后一个
        /// </summary>
        /// <param name="cellCode"></param>
        /// <returns></returns>
        bool GetTemporary(out int status,string cellCode);

        /// <summary>
        /// 根据物料编码查询其他信息
        /// </summary>
        /// <param name="MaterialCode"></param>
        /// <returns></returns>
        ShippingByMaterialCodeDto GetShippingByMaterialCode(out string message ,string MaterialCode);

        /// <summary>
        /// 根据仓位查库存数量
        /// </summary>
        /// <param name="CellCode"></param>
        /// <returns></returns>
        decimal? GetQtyByCellCode(string locationCode);


    }
}
